<?php

/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Badge
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */

class Badge_Form_Admin_Award_Filter extends Engine_Form {
	
	public function init() {
		
		$this->clearDecorators ()->addDecorator ( 'FormElements' )->addDecorator ( 'Form' )->addDecorator ( 'HtmlTag', array ('tag' => 'div', 'class' => 'search' ) )->addDecorator ( 'HtmlTag2', array ('tag' => 'div', 'class' => 'clear' ) );
		
		$this->setAttribs ( array ('id' => 'filter_form', 'class' => 'global_form_box' ) );
		
		$badgeOptions = Engine_Api::_ ()->badge ()->getBadgesAsSubOptions ( Badge_Model_Badge::MEMBERSHIP_TYPE_AWARD );
		$badgeOptions = array ("" => "" ) + $badgeOptions;
		
		// category field
		$this->addElement ( 'Select', 'badge', array ('label' => 'Badge', 'multiOptions' => $badgeOptions, 'filters' => array (new Radcodes_Lib_Filter_Null () ) ) );
		
		$this->addElement ( 'Text', 'user', array ('label' => 'Member' ) );
		
		$this->addElement ( 'Text', 'keyword', array ('label' => 'Keyword' ) );
		
		$this->addElement ( 'Select', 'active', array ('label' => 'Active', 'multiOptions' => array ("" => "", "1" => "Yes", "0" => "No" ), 'filters' => array ()//new Radcodes_Lib_Filter_Null()
		 ) );
		
		$this->addElement ( 'Select', 'featured', array ('label' => 'Featured', 'multiOptions' => array ("" => "", "1" => "Yes", "0" => "No" ), 'filters' => array ()//new Radcodes_Lib_Filter_Null()
		 ) );
		
		foreach ( $this->getElements () as $fel ) {
			if ($fel instanceof Zend_Form_Element) {
				
				$fel->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'Label', array ('tag' => null, 'placement' => 'PREPEND' ) )->addDecorator ( 'HtmlTag', array ('tag' => 'div', 'id' => $fel->getName () . '-search-wrapper', 'class' => 'form-search-wrapper' ) );
			
			}
		}
		
		$submit = new Engine_Form_Element_Button ( 'filtersubmit', array ('type' => 'submit' ) );
		$submit->setIgnore ( true )->setLabel ( 'Search' )->clearDecorators ()->addDecorator ( 'ViewHelper' )->addDecorator ( 'HtmlTag', array ('tag' => 'div', 'class' => 'buttons' ) )->addDecorator ( 'HtmlTag2', array ('tag' => 'div' ) );
		
		$this->addElement ( $submit );
		
		$this->addElement ( 'Hidden', 'order', array ('order' => 1001 ) );
		
		$this->addElement ( 'Hidden', 'order_direction', array ('order' => 1002 ) );
		
		$this->setAction ( Zend_Controller_Front::getInstance ()->getRouter ()->assemble ( array ('module' => 'badge', 'controller' => 'awards' ), 'admin_default', true ) );
	
	}

}